
#include "at32f435_437_clock.h"
#include "pin.h"
#include "status_light.h"
#include "FreeRTOS.h"
#include "task.h"

TaskHandle_t SL_Handler;

void SL_task_function(void* pvParameters);


/**
 * @brief  main function.
 * @param  none
 * @retval none
 */
int main(void)
{
    system_clock_config();
	nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
    system_periph_clock_config();
    pin_init();

    taskENTER_CRITICAL();

    xTaskCreate((TaskFunction_t )SL_task_function,
                (const char*    )"SL Handler",
                (uint16_t       )512,
                (void*          )NULL,
                (UBaseType_t    )2,
                (TaskHandle_t*  )&SL_Handler);

    taskEXIT_CRITICAL();

	vTaskStartScheduler();
	
    while (1)
    {
        vTaskDelay(1000);
    }
}

/**
 * @brief LED闪烁
 * 
 * @param pvParameters 
 */
void SL_task_function(void* pvParameters)
{
    while (1)
    {
        SL_set_status(3);
        vTaskDelay(500);
        SL_set_status(2);
        vTaskDelay(500);
        SL_set_status(1);
        vTaskDelay(500);
        SL_set_status(0);
        vTaskDelay(500);
    }
}

/**
 * @}
 */

/**
 * @}
 */
